﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SharePointClientHelper
{
    public partial class MoveDoc : Form
    {
        public MoveDoc()
        {
            InitializeComponent();
            SPClientHelper spcHelper = SPClientHelper.GetSPClientHelper();
            List<MyDocumentLibrary> lstMyGroups = spcHelper.GetAllDocumentLibrary();

            ddlDocLib.DataSource = lstMyGroups;
            ddlDocLib.DisplayMember = "Name";
            ddlDocLib.ValueMember = "GUID";
        }

        private void ddlDocLib_SelectedIndexChanged(object sender, EventArgs e)
        {            
            if (ddlDocLib.SelectedIndex > 0)
            {
                MyDocumentLibrary docLib = (MyDocumentLibrary)ddlDocLib.SelectedItem;
                SPClientHelper spcHelper = SPClientHelper.GetSPClientHelper();
                List<MyDocumentLibrary> lstMyGroups = spcHelper.GetAllDocuments(docLib.Name);

                grdDocuments.DataSource = lstMyGroups;
            }
        }

        private void btnMove_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedRowCollection selectedDocs = grdDocuments.SelectedRows;
            foreach (DataGridViewRow gr in selectedDocs)
            {
                MyDocumentLibrary document = (MyDocumentLibrary) gr.DataBoundItem;
                MessageBox.Show(document.Name);
            }
        }
    }
}
